package chess_game_5;

import java.util.ArrayList;
import java.util.List;

//新增父类，用于定义一些基础方法与变量
//子类为 ReverciGame 和 PeaceGame 
//根据老师的建议进行了更改，使用了继承的方式设计了两种游戏模式
public abstract class Game {
    // protect 仅父类与子类可用
    protected char[][] board;
    protected Player player;
    protected int gameId;
    protected String mode;
    protected int round; // Gomoku专用：记录当前轮数
    protected List<int[]> legalMoves = new ArrayList<>();

    public Game(String player1, String player2, int gameId, String mode) {
        this.player = new Player(player1, player2);
        this.gameId = gameId;
        this.mode = mode;
        initializeBoard();
    }

    public abstract void initializeBoard();

    public abstract boolean isValidMove(int row, int col);

    public abstract boolean placeChess(int row, int col);

    public abstract boolean isGameOver();

    public abstract String getScoreInfo();

    // 新增方法（Gomoku需要）
    public int getRound() {
        return round;
    }

    public char[][] getBoard() {
        return board;
    }

    // reversi需要
    public List<int[]> getLegalMoves() {
        return legalMoves;
    }

    public String getMode() {
        return mode;
    }

    public int getGameId() {
        return gameId;
    }

    public Player getPlayer() {
        return player;
    }
}